﻿@*@{
    var date = Request.QueryString["date"] != "" ? Request.QueryString["date"].xFormatDateTime("yyyy-MM-dd") : Request.RequestContext.RouteData.Values["date"].xFormatDateTime("yyyy-MM-dd");
}*@
<template>
    <div v-cloak class="flex-column hidden-x bg-light">
        <component is="style" />
        <week-calendars v-model="date" :list="weekList" v-on:click="getSchedule"></week-calendars>
        <div class="flex-column-fill">
            <van-empty v-if="!list||list.length==0" description="今天没有课" />
            <template v-else>
                <div class="padding-tb-6" v-for="(item,index) in list" :key="index">
                    <van-cell-group inset>
                        <van-cell :border="false" class="shadow-1">
                            <template #title>
                                <van-tag color="#ffe1e1" text-color="#ad0000" class="margin-right-sm"
                                         size="medium">课程</van-tag> {{item.cilName}}
                            </template>
                        </van-cell>
                        <van-cell title-style="flex:none;min-width:150rpx;" title="上课时间" :border="false">
                            {{item.cliStartTime}} 到 {{item.cliFinishTime}}
                        </van-cell>
                        <van-cell title-style="flex:none;min-width:150rpx;" title="上课地点" :border="false">
                            {{item.liName}}
                        </van-cell>
                    </van-cell-group>
                    
                </div>
            </template>
        </div>
    </div>
</template>
<script>
    module = (function (hxt) {
        return {
            name: 'scTimetable',
            props: {
               
            },
            data: function () {
                return {
                    optor: hxt.store.optor,
                    date: hxt.dateFormat("yyyy-MM-dd"),
                    weekList: [],
                    list: [],
                };
            },
            watch: {
                date: {
                    handler: function (val, old) {
                        var _this = this;
                        _this.loadList();
                    },
                    immediate: true
                }
            },
            computed: {

            },
            activated: function () {

            },
            mounted: function () {
                var _this = this;
                _this.$parent.showHome = true;
                _this.getSchedule();
            },
            methods: {
                getSchedule: function (date) {
                    var _this = this;
                    _this.weekList = [];
                    hxt.post({
                        url: hxt.config.link + "pc/wxGetSchedule",
                        data: {
                            date: _this.date
                        },
                        ok: function (res) {
                            if (res.code != 0) return hxt.error(res.errmsg, '加载失败');
                            _this.weekList = res.data;
                        },

                    });
                },
                loadList: function () {
                    var _this = this;
                    _this.list = [];
                    hxt.post({
                        url: hxt.config.link + "pc/wxGetScheduleTaskList",
                        data: {
                            date: _this.date
                        },
                        ok: function (res) {
                            if (res.code != 0) return hxt.error(res.errmsg, '加载失败');
                            _this.list = res.data;
                        },

                    });
                }
            },
            components: {
                weekCalendars: function () { return hxt.staticComponent(@Html.Raw(this.vueComponent("~/Views/wx/app/week-calendars.cshtml"))); },
            }
        };
    })(window.$jscript.fn);
</script>
<style>
    .van-cell + .van-cell {
        padding-top: 0;
    }
</style>